﻿using System;
using System.Collections;
using System.Linq;
using System.Windows.Forms;
using System.Web;
using System.Drawing;
using System.Configuration;
using System.Diagnostics;
//using Resolution;

namespace CarlowPitBoy
{
    static class Program
    {
        private static Point gameResolution = new Point(1680, 1040);
        private static Screen gameScreen = Screen.PrimaryScreen;
        
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Screen primaryScreen = Screen.PrimaryScreen;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            //create the form and show it
            alterResolution(gameResolution) ;
            Map map = new Map();
            TileMenu tileMenu = new TileMenu();
            map.AddOwnedForm(tileMenu);
            map.Show();
            tileMenu.generateButtons();
            tileMenu.Show();
            tileMenu.Activate();
            //store time information for controlling the speed of the loop
            DateTime lastTime = new DateTime();
            DateTime currentTime = new DateTime();
            TimeSpan t = new TimeSpan();
            lastTime = DateTime.Now;

            //loop while the form is running
            while (tileMenu.Created)
            {
                currentTime = DateTime.Now;
                //get the number of milliseconds passed since lastTime
                t = currentTime - lastTime;
                if (t.TotalMilliseconds > 25)
                {
                    UniversalProperties.updateMousePosition();

                    map.updateWorld();
                    tileMenu.updateWorld();

                    map.buttonUpdate();
                    tileMenu.buttonUpdate();

                    Application.DoEvents();

                    map.Invalidate();
                    tileMenu.Invalidate();

                    lastTime = DateTime.Now;
                }//end if
            }//end while
            returnOriginalRes(UniversalProperties.originalPrimaryScreen.Bounds.Width, UniversalProperties.originalPrimaryScreen.Bounds.Height);
        }

        private static void alterResolution(Point gameResolution)
        {
            
        }

        private static void returnOriginalRes(int width, int height)
        {
            //Process resAlteration = new Process();
            //resAlteration.StartInfo.FileName = @"Startup\QRes.exe";
            //resAlteration.StartInfo.Arguments = "/x 800 /y 600";
            //resAlteration.Start();
            //resAlteration.WaitForExit();
        }

    }
}
